/*
 * Types.java
 *
 * Created on 24 marzo 2004, 8.17
 */

package net.ermannofranco.xml.schema;

import java.util.ArrayList;
import java.util.List;

/**
 * Rappresenta i tipi semplici xml.
 * 
 * @author ermanno (ermanno.franco@gmail.com)
 */
public enum XmlType implements BaseTypeContainer {

	// public static final int NO_NAME=-9999;// RESTITUISCE STRINGA NULLA

	ANYTYPE, ANYSIMPLETYPE, STRING, BOOLEAN, BASE_64_BIN, HEXB, FLOAT, DECIMAL, DOUBLE, ANYURI, QNAME, NOTATION, DURATION, DATETIME, TIME, DATE, GREG_YEARMONTH, GREG_YEAR, GREG_MONTHDAY, GREG_DAY, GREG_MONTH, NORMAL_STRING, TOKEN, LANGUAGE, NAME, NCNAME, ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS, INTEGER, NON_POS_INTEGER, NEG_INTEGER, LONG, INT, SHORT, BYTE, NON_NEG_INTEGER, UNSIGNED_LONG, UNSIGNED_INT, UNSIGNED_SHORT, UNSIGNED_BYTE, POS_INTEGER;
	/**
	 * ottiene la stringa corrispondente, O GENERA ECCEZIONE
	 * 
	 * @param typeNumber
	 *            id del tipo
	 * @return la stringa corrispondente, O GENERA ECCEZIONE
	 */
	public static String getType(XmlType typeNumber) {
		switch (typeNumber) {
		case ANYTYPE:
			return "anyType";
		case ANYSIMPLETYPE:
			return "anySimpleType";
		case STRING:
			return "string";
		case BOOLEAN:
			return "boolean";
		case BASE_64_BIN:
			return "base64Binary";
		case HEXB:
			return "hexBinary";
		case FLOAT:
			return "float";
		case DECIMAL:
			return "decimal";
		case DOUBLE:
			return "double";
		case ANYURI:
			return "anyURI";
		case QNAME:
			return "QName";
		case NOTATION:
			return "NOTATION";
		case DURATION:
			return "duration";
		case DATETIME:
			return "dateTime";
		case TIME:
			return "time";
		case DATE:
			return "date";
		case GREG_YEARMONTH:
			return "gYearMonth";
		case GREG_YEAR:
			return "gYear";
		case GREG_MONTHDAY:
			return "gMonthDay";
		case GREG_DAY:
			return "gDay";
		case GREG_MONTH:
			return "gMonth";

		case NORMAL_STRING:
			return "normalizedString";
		case TOKEN:
			return "token";
		case LANGUAGE:
			return "language";
		case NAME:
			return "Name";
		case NCNAME:
			return "NCName";
		case ID:
			return "ID";
		case IDREF:
			return "IDREF";
		case IDREFS:
			return "IDREFS";
		case ENTITY:
			return "ENTITY";
		case ENTITIES:
			return "ENTITIES";
		case NMTOKEN:
			return "NMTOKEN";
		case NMTOKENS:
			return "NMTOKENS";
		case INTEGER:
			return "integer";
		case NON_POS_INTEGER:
			return "nonPositiveInteger";
		case NEG_INTEGER:
			return "negativeInteger";
		case LONG:
			return "long";
		case INT:
			return "int";
		case SHORT:
			return "short";
		case BYTE:
			return "byte";
		case NON_NEG_INTEGER:
			return "nonNegativeInteger";
		case UNSIGNED_LONG:
			return "unsignedLong";
		case UNSIGNED_INT:
			return "unsignedInt";
		case UNSIGNED_SHORT:
			return "unsignedShort";
		case UNSIGNED_BYTE:
			return "unsignedByte";
		case POS_INTEGER:
			return "positiveInteger";
		default:
			throw new SchemaException("Tipo non accettato");
		}
		// return null;
	}

	/**
	 * @return a list with one element. 
	 */
	public List<XmlType> getBaseTypes() {
		List<XmlType> ret = new ArrayList<XmlType>();
		ret.add(this);
		return ret;
	}

}
